<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/angular.min.js"></script>
</head>
<body>
    <div ng-app="myapp" ng-controller="myctrl">
        <table width="100%" border="1">
            <tr>
                <td>序号</td>
                <td>商品编号</td>
                <td>商品名称</td>
                <td>价格</td>
            </tr>
            <!--ng-repeat遍历-->
            <tr ng-repeat="product in products">
                <td>{{$index+1}}</td>
                <td>{{product.id}}</td>
                <td>{{product.name}}</td>
                <td>{{product.price}}</td>
            </tr>
        </table>
    <div>
        <!--ng-model模型作用域-->
        <input type="text" name="name" ng-model="name"/>
        <!--提供按钮-->
        <input type="button" value="清空" ng-click="clearVal()"/>
    </div>
    <div>
        hello,{{name}}
    </div>
    </div>
    <script type="text/javascript">
        var myapp= angular.module("myapp",[]);
        myapp.controller("myctrl",["$scope",function ($scope) {
            $scope.name = "黑马程序员";
            $scope.clearVal = function () {
                $scope.name="";
            }
            $scope.products = [
                {
                    id:1001,
                    name:'数码相机',
                    price:3000
                },
                {
                    id:1002,
                    name:'苹果',
                    price:7000
                }
            ];
        }])
    </script>
</body>
</html>